<?php
include "../tambah/date.php";
include "../txt/url.php";
if (!isset($_SESSION)) {
  session_start();
}
$per_page=6;
include_once('../Connections/sepolwan_connect.php');
if(isset($_POST['pageLimit']) && !empty($_POST['pageLimit'])){
    $pageLimit=$_POST['pageLimit'];
}else{
    $pageLimit='0';
}
$pageLimit=$pageLimit;

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_sesi_member = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_sesi_member = $_SESSION['MM_Username'];
}
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_sesi_member = sprintf("SELECT * FROM memberdb WHERE email = %s", GetSQLValueString($colname_sesi_member, "text"));
$sesi_member = mysql_query($query_sesi_member, $sepolwan_connect) or die(mysql_error());
$row_sesi_member = mysql_fetch_assoc($sesi_member);
$totalRows_sesi_member = mysql_num_rows($sesi_member);

mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_mm_user = "SELECT * FROM memberdb WHERE nama_user = '".$_GET['user']."' ORDER BY id DESC";
$mm_user = mysql_query($query_mm_user, $sepolwan_connect) or die(mysql_error());
$row_mm_user = mysql_fetch_assoc($mm_user);
$totalRows_mm_user = mysql_num_rows($mm_user);

mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_ikut = "SELECT * FROM ikut WHERE dari = '".$row_sesi_member['id']."' ORDER BY id DESC";
$ikut = mysql_query($query_ikut, $sepolwan_connect) or die(mysql_error());
$row_ikut = mysql_fetch_assoc($ikut);
$totalRows_ikut = mysql_num_rows($ikut);

$aaaaaaa = "-1";
if (isset($row_mm_user['id'])) {
  $aaaaaaa = $row_mm_user['id'];
}

mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
 $query_tl_user = sprintf("SELECT * FROM dinding_tl WHERE me = %s ORDER BY id DESC limit ".$pageLimit.",".$per_page, GetSQLValueString( $aaaaaaa , "text"));
$tl_user = mysql_query($query_tl_user, $sepolwan_connect) or die(mysql_error());
$row_tl_user = mysql_fetch_assoc($tl_user);
$totalRows_tl_user = mysql_num_rows($tl_user);
?>
<?php 
 if ($totalRows_tl_user > 0) { // Show if recordset not empty 
 ?>
  
  <table width="590" border="0" align="center" cellpadding="0" cellspacing="0">
         
         <?php  if  ($totalRows_tl_user>0) { do { 
		?>
        <tr>
           <td valign="top">
           <div style="height:10px"></div>
<div id="halaman">
    
      <?php
	mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_mm = "SELECT * FROM memberdb WHERE id=".$row_tl_user['me']." ";
$mm = mysql_query($query_mm, $sepolwan_connect) or die(mysql_error());
$row_mm = mysql_fetch_assoc($mm);
$totalRows_mm = mysql_num_rows($mm);
	?>
  <div style="width:50px; height:50px; float:left; overflow:hidden; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; margin-right:10px; margin-bottom:10px"><a href="<?php echo $row_mm['nama_user'] ?>" target="_parent"><img src="<?php if(file_exists("../images/member/ava/resize_50_50_".md5($row_mm['id']).".jpg")) { echo $base."images/member/ava/resize_50_50_".md5($row_mm['id']).".jpg"; } else { if(file_exists("../images/member/ava/".md5($row_mm['id']).".jpg")) { echo $base."images/member/ava/tester_50_50_".md5($row_mm['id']).".jpg"; } else { echo $base."images/member/ava/resize_50_50_default.jpg"; } } ?>" /></a> </div>
  <p><strong><a href="<?php echo $base.$row_mm['nama_user'] ?>"><?php echo $row_mm['full_name'] ?> (<?php echo $row_mm['nama_user'] ?>)</a></strong><br />

  <font size="-5" color="#999999"><?php echo tgl_indo($row_tl_user['waktu']), substr($row_tl_user['waktu'], 10, 6), " WIB"; ?> </font> </p>

   <div style="width:100%; height:1px; background:#CCC; margin-top:20px"></div>
  <p><strong><a href="../<?php  if ($row_tl_user['judul']<>"") {  
	echo $row_mm['nama_user']."/artikel/".$row_tl_user['id']."-".str_replace(array(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '{', '}', '|', ',', ':', ';', '"', '<', '>', ',', '.', '?', '/'), '-', $row_tl_user['judul']); 
	} else {
		echo $row_mm['nama_user']."/artikel/".$row_tl_user['id']."-post";
	}?>.html"><?php echo $row_tl_user['judul']; ?></a></strong>
  <p> <div><font style="text-justify: auto"><?php 
  
  
  if (strlen($row_tl_user['isi'])<=255) {
	  
		//echo $konten = str_replace(array("\r\n","\r","\n", "[img]", "[/img]", "[a]", "[/a]"), array("<br/>","<br/>","<br/>","<img src='","' style='max-width:500px' />", "<a href='", "' target='_blank'>&gt;&gt; Klik Disini &lt;&lt;</a>" ),$row_tl_user['isi']);// 
		echo
preg_replace('~@([^\s#@]+)~','<a href="http://geriloji.com/\1" target="_parent">$0</a>',
str_replace(array(":anger",":burn",":confused",":cool",":cry",":fire",":grimace",":love",":miao",":prettiness",":question",":shout",":slobber",":smile",":spook",":startle",":surprise",":sweat",":thirst",":vomit"), array("<img src='".$base."images/icon/anger.PNG' />","<img src='".$base."images/icon/burn.PNG' />","<img src='".$base."images/icon/confused.PNG' />","<img src='".$base."images/icon/cool.PNG' />","<img src='".$base."images/icon/cry.PNG' />","<img src='".$base."images/icon/fire.PNG' />","<img src='".$base."images/icon/grimace.PNG' />","<img src='".$base."images/icon/love.PNG' />","<img src='".$base."images/icon/miao.PNG' />","<img src='".$base."images/icon/prettiness.PNG' />","<img src='".$base."images/icon/question.PNG' />","<img src='".$base."images/icon/shout.PNG' />","<img src='".$base."images/icon/slobber.PNG' />","<img src='".$base."images/icon/smile.PNG' />","<img src='".$base."images/icon/spook.PNG' />","<img src='".$base."images/icon/startle.PNG' />","<img src='".$base."images/icon/surprise.PNG' />","<img src='".$base."images/icon/sweat.PNG' />","<img src='".$base."images/icon/thirst.PNG' />","<img src='".$base."images/icon/vomit.PNG' />"),
	str_replace(array("\r\n","\r","\n"), "<br />",
	preg_replace('/{img.*}(.*?){.*\/?img}/','<img src="\1" style="max-width:400px"/>',
	preg_replace('/{url.*}(.*?){.*\/?url}/','<a href="\1" target="_blank">\1</a>',
	preg_replace('/{b.*}(.*?){.*\/?b}/','<strong>\1</strong>',
	preg_replace('/{i.*}(.*?){.*\/?i}/','<i>\1</i>',
	preg_replace('/{youtube.*}(.*?){.*\/?youtube}/','<iframe width="400" height="280" src="//www.youtube.com/embed/\1" frameborder="0" allowfullscreen></iframe>',
	preg_replace('~#([^\s#@]+)~','<a href="search/\1">$0</a>', substr($row_tl_user['isi'], 0, 150))))))))));
		
		
  } else if  (strlen($row_tl_user['isi'])>255) {
		
		
	  	echo preg_replace('~@([^\s#@]+)~','<a href="http://geriloji.com/\1" target="_parent">$0</a>',
str_replace(array(":anger",":burn",":confused",":cool",":cry",":fire",":grimace",":love",":miao",":prettiness",":question",":shout",":slobber",":smile",":spook",":startle",":surprise",":sweat",":thirst",":vomit"), array("<img src='".$base."images/icon/anger.PNG' />","<img src='".$base."images/icon/burn.PNG' />","<img src='".$base."images/icon/confused.PNG' />","<img src='".$base."images/icon/cool.PNG' />","<img src='".$base."images/icon/cry.PNG' />","<img src='".$base."images/icon/fire.PNG' />","<img src='".$base."images/icon/grimace.PNG' />","<img src='".$base."images/icon/love.PNG' />","<img src='".$base."images/icon/miao.PNG' />","<img src='".$base."images/icon/prettiness.PNG' />","<img src='".$base."images/icon/question.PNG' />","<img src='".$base."images/icon/shout.PNG' />","<img src='".$base."images/icon/slobber.PNG' />","<img src='".$base."images/icon/smile.PNG' />","<img src='".$base."images/icon/spook.PNG' />","<img src='".$base."images/icon/startle.PNG' />","<img src='".$base."images/icon/surprise.PNG' />","<img src='".$base."images/icon/sweat.PNG' />","<img src='".$base."images/icon/thirst.PNG' />","<img src='".$base."images/icon/vomit.PNG' />"),
	str_replace(array("\r\n","\r","\n"), "<br />",
	preg_replace('/{img.*}(.*?){.*\/?img}/','<img src="\1" style="max-width:400px"/>',
	preg_replace('/{url.*}(.*?){.*\/?url}/','<a href="\1" target="_blank">\1</a>',
	preg_replace('/{b.*}(.*?){.*\/?b}/','<strong>\1</strong>',
	preg_replace('/{i.*}(.*?){.*\/?i}/','<i>\1</i>',
	preg_replace('/{youtube.*}(.*?){.*\/?youtube}/','<iframe width="400" height="280" src="//www.youtube.com/embed/\1" frameborder="0" allowfullscreen></iframe>',
	preg_replace('~#([^\s#@]+)~','<a href="search/\1">$0</a>', substr($row_tl_user['isi'], 0, 150))))))))));
		echo " <font size='-3'><a href='".$base.$row_mm['nama_user']."/artikel/".$row_tl_user['id']."-".str_replace(array(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '{', '}', '|', ',', ':', ';', '"', '<', '>', ',', '.', '?', '/'), '-', $row_tl_user['judul'])."post.html' target='_parent' >Selengkapnya&gt;&gt;</a></font>"; 
  }
  
  
   ?></font></div></p>
   <?php if ($row_tl_user['jenis']=='komentar') { ?>
   <font size="-3">commented on this.</font>
   <div style="padding:10px; background:#EFEFEF">
    <?php
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
 $query_tl_userform = "SELECT * FROM dinding_tl WHERE id = '".$row_tl_user['form']."' ";
$tl_userform = mysql_query($query_tl_userform, $sepolwan_connect) or die(mysql_error());
$row_tl_userform = mysql_fetch_assoc($tl_userform);
$totalRows_tl_userform = mysql_num_rows($tl_userform);	

	mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_form = "SELECT * FROM memberdb WHERE id=".$row_tl_userform['me']." ";
$form = mysql_query($query_form, $sepolwan_connect) or die(mysql_error());
$row_form = mysql_fetch_assoc($form);
$totalRows_form = mysql_num_rows($form);
	?>
   <div style="width:50px; height:50px; float:left; overflow:hidden; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; margin-right:10px; margin-bottom:10px"><a href="<?php echo $row_form['nama_user'] ?>" target="_parent"><img src="<?php if(file_exists("../images/member/ava/resize_50_50_".md5($row_form['id']).".jpg")) { echo $base."images/member/ava/resize_50_50_".md5($row_form['id']).".jpg"; } else { if(file_exists("../images/member/ava/".md5($row_form['id']).".jpg")) { echo $base."images/member/ava/tester_50_50_".md5($row_form['id']).".jpg"; } else { echo $base."images/member/ava/resize_50_50_default.jpg"; } } ?>" /></a> </div>
  <p><strong><a href="<?php echo $base.$row_form['nama_user'] ?>"><?php echo $row_form['full_name'] ?> (<?php echo $row_form['nama_user'] ?>)</a></strong><br />

  <font size="-5" color="#999999"><?php echo tgl_indo($row_tl_userform['waktu']), substr($row_tl_userform['waktu'], 10, 6), " WIB"; ?> </font> </p>

   <div style="width:100%; height:1px; background:#CCC; margin-top:20px"></div>
  <p><strong><a href="../<?php  if ($row_tl_userform['judul']<>"") {  
	echo $row_form['nama_user']."/artikel/".$row_tl_user['id']."-".str_replace(array(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '{', '}', '|', ',', ':', ';', '"', '<', '>', ',', '.', '?', '/'), '-', $row_tl_userform['judul']); 
	} else {
		echo $row_mm['nama_user']."/artikel/".$row_tl_userform['id']."-post";
	}?>.html"><?php echo $row_tl_userform['judul']; ?></a></strong>
  <p> <div><font style="text-justify: auto"><?php 
  
  
  if (strlen($row_tl_userform['isi'])<=255) {
	  
		//echo $konten = str_replace(array("\r\n","\r","\n", "[img]", "[/img]", "[a]", "[/a]"), array("<br/>","<br/>","<br/>","<img src='","' style='max-width:500px' />", "<a href='", "' target='_blank'>&gt;&gt; Klik Disini &lt;&lt;</a>" ),$row_tl_user['isi']);// 
		echo
preg_replace('~@([^\s#@]+)~','<a href="http://geriloji.com/\1" target="_parent">$0</a>',

str_replace(array(":anger",":burn",":confused",":cool",":cry",":fire",":grimace",":love",":miao",":prettiness",":question",":shout",":slobber",":smile",":spook",":startle",":surprise",":sweat",":thirst",":vomit"), array("<img src='".$base."images/icon/anger.PNG' />","<img src='".$base."images/icon/burn.PNG' />","<img src='".$base."images/icon/confused.PNG' />","<img src='".$base."images/icon/cool.PNG' />","<img src='".$base."images/icon/cry.PNG' />","<img src='".$base."images/icon/fire.PNG' />","<img src='".$base."images/icon/grimace.PNG' />","<img src='".$base."images/icon/love.PNG' />","<img src='".$base."images/icon/miao.PNG' />","<img src='".$base."images/icon/prettiness.PNG' />","<img src='".$base."images/icon/question.PNG' />","<img src='".$base."images/icon/shout.PNG' />","<img src='".$base."images/icon/slobber.PNG' />","<img src='".$base."images/icon/smile.PNG' />","<img src='".$base."images/icon/spook.PNG' />","<img src='".$base."images/icon/startle.PNG' />","<img src='".$base."images/icon/surprise.PNG' />","<img src='".$base."images/icon/sweat.PNG' />","<img src='".$base."images/icon/thirst.PNG' />","<img src='".$base."images/icon/vomit.PNG' />"),
	str_replace(array("\r\n","\r","\n"), "<br />",
	preg_replace('/{img.*}(.*?){.*\/?img}/','<img src="\1" style="max-width:400px"/>',
	preg_replace('/{url.*}(.*?){.*\/?url}/','<a href="\1" target="_blank">\1</a>',
	preg_replace('/{b.*}(.*?){.*\/?b}/','<strong>\1</strong>',
	preg_replace('/{i.*}(.*?){.*\/?i}/','<i>\1</i>',
	preg_replace('/{youtube.*}(.*?){.*\/?youtube}/','<iframe width="400" height="280" src="//www.youtube.com/embed/\1" frameborder="0" allowfullscreen></iframe>',
	preg_replace('~#([^\s#@]+)~','<a href="search/\1">$0</a>', substr($row_tl_userform['isi'], 0, 150))))))))));
		
		
  } else if  (strlen($row_tl_userform['isi'])>255) {
		
		
	  	echo preg_replace('~@([^\s#@]+)~','<a href="http://geriloji.com/\1" target="_parent">$0</a>',
str_replace(array(":anger",":burn",":confused",":cool",":cry",":fire",":grimace",":love",":miao",":prettiness",":question",":shout",":slobber",":smile",":spook",":startle",":surprise",":sweat",":thirst",":vomit"), array("<img src='".$base."images/icon/anger.PNG' />","<img src='".$base."images/icon/burn.PNG' />","<img src='".$base."images/icon/confused.PNG' />","<img src='".$base."images/icon/cool.PNG' />","<img src='".$base."images/icon/cry.PNG' />","<img src='".$base."images/icon/fire.PNG' />","<img src='".$base."images/icon/grimace.PNG' />","<img src='".$base."images/icon/love.PNG' />","<img src='".$base."images/icon/miao.PNG' />","<img src='".$base."images/icon/prettiness.PNG' />","<img src='".$base."images/icon/question.PNG' />","<img src='".$base."images/icon/shout.PNG' />","<img src='".$base."images/icon/slobber.PNG' />","<img src='".$base."images/icon/smile.PNG' />","<img src='".$base."images/icon/spook.PNG' />","<img src='".$base."images/icon/startle.PNG' />","<img src='".$base."images/icon/surprise.PNG' />","<img src='".$base."images/icon/sweat.PNG' />","<img src='".$base."images/icon/thirst.PNG' />","<img src='".$base."images/icon/vomit.PNG' />"),
	str_replace(array("\r\n","\r","\n"), "<br />",
	preg_replace('/{img.*}(.*?){.*\/?img}/','<img src="\1" style="max-width:400px"/>',
	preg_replace('/{url.*}(.*?){.*\/?url}/','<a href="\1" target="_blank">\1</a>',
	preg_replace('/{b.*}(.*?){.*\/?b}/','<strong>\1</strong>',
	preg_replace('/{i.*}(.*?){.*\/?i}/','<i>\1</i>',
	preg_replace('/{youtube.*}(.*?){.*\/?youtube}/','<iframe width="400" height="280" src="//www.youtube.com/embed/\1" frameborder="0" allowfullscreen></iframe>',
	preg_replace('~#([^\s#@]+)~','<a href="search/\1">$0</a>', substr($row_tl_userform['isi'], 0, 150))))))))));
		echo " <font size='-3'><a href='".$base.$row_form['nama_user']."/artikel/".$row_tl_userform['id']."-".str_replace(array(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '{', '}', '|', ',', ':', ';', '"', '<', '>', ',', '.', '?', '/'), '-', $row_tl_userform['judul'])."post.html' target='_parent' >Selengkapnya&gt;&gt;</a></font>"; 
  }
  

  
   ?></font></div>
   
   
   </div><?php } ?>
  </p>
    </div>
    <div style="padding:10px; background: #EFEFEF; border:1px solid #CCC;" align="center"><font size="-5" color="#999999"><?php if ($row_tl_user['jenis']<>'komentar') { ?><a href="<?php  if ($row_tl_user['judul']<>"") {  
	echo $row_mm['nama_user']."/artikel/".$row_tl_user['id']."-".str_replace(array(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '{', '}', '|', ',', ':', ';', '"', '<', '>', ',', '.', '?', '/'), '-', $row_tl_user['judul']); 
	} else {
		echo $base.$row_mm['nama_user']."/artikel/".$row_tl_user['id']."-post";
	}?>.html" target="_parent">Lihat Detail</a> <?php } else { ?> 
      <a href="<?php  if ($row_tl_userform['judul']<>"") {  
	echo $row_form['nama_user']."/artikel/".$row_tl_userform['id']."-".str_replace(array(' ', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '{', '}', '|', ',', ':', ';', '"', '<', '>', ',', '.', '?', '/'), '-', $row_tl_user['judul']); 
	} else {
		echo $base.$row_form['nama_user']."/artikel/".$row_tl_userform['id']."-post";
	}?>.html">Lihat Percakapan</a>
      <?php } ?><?php if ($row_sesi_member['id']==$row_tl_user['me']) { ?>| <a href="<?php echo $base ?>action/deletepost.php?id=<?php echo $row_tl_user['id']; ?>&me=<?php echo $row_tl_user['me']; ?>">delete</a><?php } ?> </font></div>
    </td>
	</tr><?php
	
		mysql_free_result($mm);
	 } while ($row_tl_user = mysql_fetch_array($tl_user)); } ?>
         
       </table>
  
  
  <?php
$loadCount=$pageLimit+$per_page;
 if($totalRows_tl_user >= $per_page){ ?>
       <div class="load_more_link">
       <input type="button" class="button" value="Load More" 
       onclick=loadData(<?php echo $loadCount ?>)>
       <span class="flash"></span></div> <?php
 }
 
 ?>
 <?php
}
else { ?><br />
<div id="halaman" align="center">Belum Ada Post </div><?php }
mysql_free_result($tl_user);

?>